package com.yzc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yzc.model.DTO.AttractionOrderDetail;
import com.yzc.model.entity.system.Tour;
import com.yzc.model.entity.ticket_order.OrderAttraction;
import com.yzc.model.vo.ticket_order.v_AttractionOrderVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TicketAttractionOrderMapper extends BaseMapper<OrderAttraction> {

    void createTicketOrder(@Param("attraction") AttractionOrderDetail attraction,@Param("orderId") long orderId);

    v_AttractionOrderVo selectUserInfoByorderId(Long orderId);

    @Select("SELECT COUNT(*) FROM order_status_log WHERE order_id = #{orderId}")
    Boolean selectOrderLog(@Param("orderId") Long orderId);

    @Select("SELECT * FROM t_tour WHERE tourid = #{attractionId}")
    Tour selectByAttractionId( Long attractionId);

    @Update("UPDATE t_tour SET stock = stock + #{ticketCount} WHERE tourid = #{tourId}")
    int updateStock(@Param("tourId") Integer tourId, @Param("ticketCount") int ticketCount);
}
